/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.distribuida.supertrunfo.facade;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

/**
 *
 * @author Notebook
 */
@WebService(serviceName = "NewWebService")
public class NewWebService {

    private static SuperTrunfoFacade superTF = new SuperTrunfoFacade();
    /**
     * This is a sample web service operation
     */
    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) {
        return "Hello " + txt + " !";
    }
    
    @WebMethod(operationName = "preRegistro")
    public int preRegistro(@WebParam(name = "nome") String nome, @WebParam(name = "id") int id){
        try {
            return superTF.preRegistro(nome, id);
        } catch (Exception ex) {
            Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            return -1;
        }
    }
    
    @WebMethod(operationName = "registro")
    public int registro(@WebParam(name = "nome") String nome) {
        try {
            return superTF.registro(nome);
        } catch (Exception ex) {
            Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            return -1;
        }
    }
    
    @WebMethod(operationName = "registro")
    public int removerJogador(@WebParam(name = "id_jogador") int id_jogador) {
        try {
            return superTF.removerJogador(id_jogador);
        } catch (Exception ex) {
            Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            return -1;
        }
    }
    
    @WebMethod(operationName = "definirCaracteristica")
    public void definirCaracteristica(@WebParam(name = "id_jogador") int id_jogador, @WebParam(name = "id_caracteristica") int id_caracteristica) {
        try {
            superTF.definirCaracteristica(id_jogador, String.valueOf(id_caracteristica));
        } catch (Exception ex) {
            Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    @WebMethod(operationName = "executarRodada")
    public void executarRodada(@WebParam(name = "id_jogador") int id_jogador) {
        try {
            superTF.ExecutarRodada(id_jogador);
        } catch (Exception ex) {
            Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    @WebMethod(operationName = "pontuaca")
    public int pontuacao(@WebParam(name = "id_jogador") int id_jogador) {
        try {
            return superTF.getPontuacao(id_jogador);
        } catch (Exception ex) {
            Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            return -1;
        }
    } 
}